﻿using CommunityToolkit.Mvvm.Input;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Input;
using VideoTools.Util;
using VideoTools.VideoView;
using VideoTools.vo;

namespace VideoTools.Commands
{
    public class RemoveWatermarkCommands : NotifyPropertyBase
    {
        private static volatile RemoveWatermarkCommands _instance;
        private static readonly object SyncRoot = new object();

        public static RemoveWatermarkCommands Instance
        {
            get
            {
                if (_instance == null)
                {
                    lock (SyncRoot)
                    {
                        if (_instance == null)
                        {
                            _instance = new RemoveWatermarkCommands();
                        }
                    }
                }

                return _instance;
            }
        }

        private RemoveWatermarkCommands()
        {
            foreach (DeviceType dt in Utils.GetAllEnumValues<DeviceType>())
            {
                DeviceTypes.Add(dt);
            }
        }
        private string _Progress;

        public string Progress
        {
            get => _Progress;
            set => SetProperty(ref _Progress, value);
        }
        private string _SpendTime;

        public string SpendTime
        {
            get => _SpendTime;
            set => SetProperty(ref _SpendTime, value);
        }
        private bool _CompatibleModeEnabled = true;

        public bool CompatibleModeEnabled
        {
            get => _CompatibleModeEnabled;
            set => SetProperty(ref _CompatibleModeEnabled, value);
        }

        private bool _CompatibleModeIsChecked = false;
        public bool CompatibleModeIsChecked
        {
            get => _CompatibleModeIsChecked;
            set => SetProperty(ref _CompatibleModeIsChecked, value);
        }
        private bool _PrevVideoButtonEnabled = true;

        public bool PrevVideoButtonEnabled
        {
            get => _PrevVideoButtonEnabled;
            set => SetProperty(ref _PrevVideoButtonEnabled, value);
        }
        private bool _PrevImageButtonEnabled = true;

        public bool PrevImageButtonEnabled
        {
            get => _PrevImageButtonEnabled;
            set => SetProperty(ref _PrevImageButtonEnabled, value);
        }
        private bool _ResetPicBoxButtonEnabled = true;

        public bool ResetPicBoxButtonEnabled
        {
            get => _ResetPicBoxButtonEnabled;
            set => SetProperty(ref _ResetPicBoxButtonEnabled, value);
        }
        private bool _StopButtonEnabled = false;

        public bool StopButtonEnabled
        {
            get => _StopButtonEnabled;
            set => SetProperty(ref _StopButtonEnabled, value);
        }
        private bool _DoitButtonEnabled = true;

        public bool DoitButtonEnabled
        {
            get => _DoitButtonEnabled;
            set => SetProperty(ref _DoitButtonEnabled, value);
        }
        private bool _OpenVideoButtonEnabled = true;

        public bool OpenVideoButtonEnabled
        {
            get => _OpenVideoButtonEnabled;
            set => SetProperty(ref _OpenVideoButtonEnabled, value);
        }
        private bool _DeviceTypeEnabled = true;

        public bool DeviceTypeEnabled
        {
            get => _DeviceTypeEnabled;
            set => SetProperty(ref _DeviceTypeEnabled, value);
        }

        private Visibility _SpendTimeVisibility = Visibility.Hidden;

        public Visibility SpendTimeVisibility
        {
            get => _SpendTimeVisibility;
            set => SetProperty(ref _SpendTimeVisibility, value);
        }

        private Visibility _ProgressVisibility = Visibility.Hidden;

        public Visibility ProgressVisibility
        {
            get => _ProgressVisibility;
            set => SetProperty(ref _ProgressVisibility, value);
        }

        private ObservableCollection<DeviceType> _DeviceTypes =
            new ObservableCollection<DeviceType>();

        public ObservableCollection<DeviceType> DeviceTypes
        {
            get => _DeviceTypes;
            set => SetProperty(ref _DeviceTypes, value);
        }

        private ICommand _ChangeDeviceTypeCommand;

        public ICommand ChangeDeviceTypeCommand =>
            _ChangeDeviceTypeCommand
            ?? (
                _ChangeDeviceTypeCommand = new RelayCommand<object>(o =>
                {
                    if (o == null)
                        return;

                    foreach (DeviceType dt in Utils.GetAllEnumValues<DeviceType>())
                    {
                        if (dt.ToString().Equals(o.ToString()))
                        {
                            RemoveWatermarkPage.Instance.DeviceType = dt;
                        }
                    }
                })
            );
    }
}
